package com.dp.order.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dp.order.dto.OutOrder;
import com.dp.order.entity.Order;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author linzizun
 * @version 1.0
 */
@Mapper
public interface OrderMapper extends BaseMapper<Order> {

    /**
     * 获取所有未导出工单
     * @return 未导出工单列表
     * @param color 颜色
     */
    @Select("SELECT tb_order.id,tb_customer.id number,tb_order.account,color,clothes_rod_length,quantity " +
            "FROM tb_order JOIN tb_customer ON tb_order.account=tb_customer.account " +
            "WHERE tb_order.has_delete=0 AND state=1 AND color=#{color}  " +
            "ORDER BY account,clothes_rod_length")
    List<OutOrder> getOutOrder(String color);

    /**
     * 获取所有未导出工单
     * @return 未导出工单列表
     * @param color 颜色
     * @param account 旺旺号
     */
    @Select("SELECT tb_order.id,tb_customer.id number,tb_order.account,color,clothes_rod_length,quantity " +
            "FROM tb_order JOIN tb_customer ON tb_order.account=tb_customer.account " +
            "WHERE tb_order.has_delete=0 AND state=1 AND color=#{color} AND tb_order.account=#{account} " +
            "ORDER BY account,clothes_rod_length")
    List<OutOrder> getOrderByAccount(@Param("color") String color,@Param("account") String account);

}
